package com.youlu.campus.admin.task;

import com.youlu.campus.service.order.EMSService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Objects;
import java.util.concurrent.TimeUnit;

@Component
public class EMSWayllBillNoTask {

    @Autowired
    private StringRedisTemplate redisTemplate;

    @Autowired
    private EMSService emsService;



    /**
     * ems运单号轨迹查询
     * 每小时执行一次
     * 每天晚上20：00~23:00触发
     */
    @Scheduled(cron = "0 0 20-23 * * ?")
    public void doHandleEmsbillNoTraceJob(){
        Boolean flag = redisTemplate.opsForValue().setIfAbsent("order:ems:trace", "1", 3L, TimeUnit.MINUTES);
        if(Objects.nonNull(flag)&&!flag){
            return;
        }
        emsService.doHandleEmsbillNoTraceJob();
    }
}
